//
//  UIBarButonItem.swift
//  MyWeiBo
//
//  Created by 牛牛很牛 on 15/12/23.
//  Copyright © 2015年 曾勇召. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    convenience init(imageName:String) {
        let highlightedImageName = imageName+"_highlighted"
        let button = UIButton()
        button.setBackgroundImage(UIImage(named: imageName), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: highlightedImageName), forState: UIControlState.Highlighted)
        button.sizeToFit()
        
        // 便利构造函数需要调用一个当前类的指定构造函数
        self.init(customView:button)
    }

}
